/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package panel;

import Auto.ChangeShow;
import java.awt.Color;
import weixin.AdminMain;

/**
 *
 * @author jerry
 */
public class OneFriendPanel extends javax.swing.JPanel {

    /**
     * 对应的微信号
     */
    public String WXUId;

    /**
     * Creates new form OneFriendPanel
     *
     * @param wxuid
     */
    public OneFriendPanel(String wxuid) {
        initComponents();
        WXUId = wxuid;
        new_msg_count.setVisible(false);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        friend_face_image = new javax.swing.JLabel();
        friend_nick_name = new javax.swing.JLabel();
        friend_username = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        last_mag = new javax.swing.JLabel();
        new_msg_count = new javax.swing.JLabel();

        setBackground(new java.awt.Color(46, 50, 56));
        setPreferredSize(new java.awt.Dimension(237, 55));
        setSize(new java.awt.Dimension(237, 55));
        addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                formMouseClicked(evt);
            }
        });
        setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
        add(friend_face_image, new org.netbeans.lib.awtextra.AbsoluteConstraints(6, 6, 45, 45));

        friend_nick_name.setFont(new java.awt.Font("Lucida Grande", 0, 14)); // NOI18N
        friend_nick_name.setForeground(new java.awt.Color(255, 255, 255));
        friend_nick_name.setText("name");
        add(friend_nick_name, new org.netbeans.lib.awtextra.AbsoluteConstraints(57, 6, 170, 22));
        add(friend_username, new org.netbeans.lib.awtextra.AbsoluteConstraints(237, 17, -1, -1));

        jSeparator1.setForeground(new java.awt.Color(41, 44, 51));
        add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, -5, 240, -1));

        last_mag.setForeground(new java.awt.Color(255, 255, 255));
        add(last_mag, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 30, 170, -1));

        new_msg_count.setBackground(new java.awt.Color(255, 51, 0));
        new_msg_count.setForeground(new java.awt.Color(255, 255, 255));
        new_msg_count.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        new_msg_count.setText("0");
        new_msg_count.setOpaque(true);
        add(new_msg_count, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 0, 20, -1));
    }// </editor-fold>//GEN-END:initComponents

    /**
     * 点击单个朋友激活事件
     *
     * @param evt
     */
    private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked
        String friend_name = friend_username.getText();
        String nick_name = friend_nick_name.getText();

        //改变聊天框的 名称
        AdminMain.friend_name.setText(nick_name);
        //改变提交按钮的朋友名记录
        AdminMain.push_msg.setActionCommand(friend_name);
        //改变现实效果,老的回复背景色,新的改变背景色,而后记录name
        if (AdminMain.SelectFriendJpanel != null) {
            AdminMain.SelectFriendJpanel.setBackground(new Color(46, 50, 56));
        }
        this.setBackground(new Color(58, 63, 69));
//        System.err.println("改变背景色");
        AdminMain.SelectFriendJpanel = this;
        //每次点击用户的时候,都要清理掉消息框内的消息
        //执行一次,请里以及加载老消息
        ChangeShow.ClearAndFormatMsgshow(WXUId,friend_name);
        //被点击的用户,消息统计数字不显示
        new_msg_count.setVisible(false);

    }//GEN-LAST:event_formMouseClicked


    // Variables declaration - do not modify//GEN-BEGIN:variables
    public javax.swing.JLabel friend_face_image;
    public javax.swing.JLabel friend_nick_name;
    public javax.swing.JLabel friend_username;
    private javax.swing.JSeparator jSeparator1;
    public javax.swing.JLabel last_mag;
    public javax.swing.JLabel new_msg_count;
    // End of variables declaration//GEN-END:variables
}
